Webpackのbundle sizeを小さくする
Tree Shaking
Dead Code Elimination
Code Splitting
dynamic import
JavaScriptのBuild Size周り
Next.jsのbundle sizeを小さくする
重複するライブラリを共有する
package.jsonでpeerDependenciesを使用する
https://qiita.com/mizchi/items/418be9abee5f785696f0#npm-の-peerdependencies
これmonorepoのときのみの話なのか
https://github.com/darrenscerri/duplicate-package-checker-webpack-plugin
ここでみた
code:js
module.exports = {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.plugins.push(new DuplicatePackageCheckerPlugin())
return config
},
}
https://numb86-tech.hatenablog.com/entry/2020/12/01/093704
optimization.splitChunks.chunk
ライブラリの重複importを避ける
これ、falseにすることで効果的になるケースもありそうmrsekut.icon
なんでdefaultでtrueじゃないんだ
optimization.splitChunksを設定することでchunkを分割できる
Granular Chunks
vendor chunk を分割する
https://qiita.com/mizchi/items/418be9abee5f785696f0#2-vendor-chunk-を分割する
ファイルチャンクの最適化
https://blog.hiroppy.me/entry/2021/08/12/092839
Module Federation
Compression
https://nextjs.org/docs/api-reference/next.config.js/compression
画像の最適化
next/legacy/image
https://github.com/cyrilwanner/next-optimized-images
https://medium.com/ne-digital/how-to-reduce-next-js-bundle-size-68f7ac70c375
6
bundle analyzeしたら画像がinline化されてたらしい
mrsekut.iconの環境では別にされてないのでスルー
webpack最適化
https://github.com/GoogleChromeLabs/webpack-libs-optimizations
https://medium.com/ne-digital/how-to-reduce-next-js-bundle-size-68f7ac70c375
の5
Performance Budget
SSG
https://redux.js.org/recipes/server-rendering
nextも
スプレッドシートで結果の管理をする
https://medium.com/ne-digital/build-frontend-performance-monitor-dashboard-using-pagespeed-insights-e807a2caa6cf
すごいなmrsekut.icon
Reduxサイズを下げる
reducer分割?
本当に寄与するのか?
code splittingする
https://redux.js.org/recipes/code-splitting
reducerを動的に追加する?
サポートするライブラリの紹介など
https://github.com/vercel/next.js/tree/canary/examples/with-redux-code-splitting
next本家のredux code splittingの例
https://github.com/dogada/fast-redux というライブラリを使っている
https://github.com/vercel/next.js/tree/canary/examples/with-redux
https://github.com/vercel/next.js/tree/canary/examples/with-redux-saga
そのた
https://www.one-tab.com/page/t4xpqNBISMmK3AiAUKID4g
https://medium.com/ne-digital/how-to-improve-lcp-and-speed-index-for-next-js-websites-f129ae776835
lcp
material-uiのminify
https://re-make.work/javascript-materialui-minify/
合ってるのか?
prod-modeではsource mapは不要
https://nextjs.org/docs/advanced-features/source-maps
prodではdefautlではfalse
https://github.com/aholachek/bundle-wizard
Bundle Wizard is a key tool to get an overview of all bundles loaded for a specific page. The best part about bundle-wizard is that it color-codes coverage for all components.
$ npx bundle-wizard https://fairprice.com.sg
Running this command will generate a color-coded visualization similar to as shown below. From this, we can easily analyze which component/library in a bundle has less coverage and needs further investigation for optimizing the bundle.
webpack拡張
https://github.com/twopluszero/next-images
https://github.com/cyrilwanner/next-compose-plugins
内容自体はどうでもいいけど、こういうふうに拡張するんやというのを見たいと思ってメモった
#??
WebpackとNextの関係
Nextを使っていても、全てのWebpackの設定できるの?
それとも限られたものしか設定できない?
nextってdefaultでterser使っているのか?
使っているとしたらwebpackのpluginのやつだと思う
https://t-cr.jp/memo/20817942cf9bf53dc
現状もすでにchunk分割されているが、どういう意図でそれぞれ分けられているのかが不明
意図を知りたい
順番に改善していく系の記事
webpackのbundle後のJavaScriptのサイズを減らしている話 | リクルート メンバーズブログ
webpackのbundle後のサイズを減らす方法を、逐次的に紹介
依存先の依存先のライブラリがでかい時の対応
https://numb86-tech.hatenablog.com/entry/2020/12/02/094910
reactをlighthouseの指摘どおりに直していく
最後の項目がRemove unused JavaScript
How to Reduce Next.js Bundle Size | NE Digital
やや参考になった
https://www.contentful.com/blog/2017/10/10/put-your-webpack-on-a-diet-part-1/
https://www.contentful.com/blog/2017/10/19/put-your-webpack-bundle-on-a-diet-part-2/
https://www.contentful.com/blog/2017/10/27/put-your-webpack-bundle-on-a-diet-part-3/
https://www.contentful.com/blog/2017/11/13/put-your-webpack-bundle-on-a-diet-part-4/
https://zenn.dev/taishi/articles/3eb7a78452d7c2
https://www.one-tab.com/page/Tzyi8MsRS-i8CMbwqF4C9g
https://developers.freee.co.jp/entry/reduced-javascript-bundle-size